<template>
	<view class="yjc">
		<headertop title="佣金池" str1="oridei"></headertop>
		<image src="https://jingwei.xunfuzhifuzaixian.com/static/images/Group 11732@2x.png" class="yjcback"
			mode="widthFix"></image>
		<view :style="{'margin-top':statusBarHeight+'px','height':barHeight+'px'}"></view>
		<view class="qbsy">
			<image src="https://jingwei.xunfuzhifuzaixian.com/static/images/Group 11883@2x.png" class="qbsyback"
				mode=""></image>
			<view class="qbsynum">
				<view class="t1">
					全部收益（元）
				</view>
				<view class="numzijin">
					{{contentobj['allmoney']}}
				</view>
			</view>
			<view class="centersy">
				<view class="djsje" style="border-right:2rpx solid  #FFFFFF;">
					<view class="tt">
						待结算（元）
					</view>
					<view class="numje">
						{{contentobj['djmoney']}}
					</view>
				</view>
				<view class="djsje">
					<view class="tt">
						已结算（元）
					</view>
					<view class="numje">
						{{contentobj['yjmoney']}}
					</view>
				</view>
			</view>
		</view>
		<view class="bottomContent">
			<image src="https://jingwei.xunfuzhifuzaixian.com/static/images/Group 11884@2x.png"
				class="bottomContentback" mode="widthFix" v-if="activenum==0"></image>

			<image src="https://jingwei.xunfuzhifuzaixian.com/static/images/Group 11885@2x.png"
				class="bottomContentback" mode="widthFix" v-else></image>


			<view class="activeboxline">
				<view :class="activenum==0?'box1':'box'" @click="activenum=0">
					待结算
					<view class="activeb" v-if="activenum==0">

					</view>
				</view>
				<view :class="activenum==1?'box1':'box'" @click="activenum=1">
					已结算
					<view class="activeb" v-if="activenum==1">

					</view>
				</view>
			</view>
			<view class="Contents">
				<view class="msgicon" v-if="!list.length">
					<image :src="'https://jingwei.xunfuzhifuzaixian.com/static/images/wxnone.png'" mode="widthFix">
					</image>
					<view class="msgtext">
						暂无内容
					</view>
				</view>
				<view class="itemnr" v-for="item in list" :key="index">
					<view class="linenr1">
						<view class="tt">
							{{item['title']}}
						</view>
						<view class="jine">
							{{item['money']}}元
						</view>
					</view>
					<view class="texts" style="font-family: PingFang SC, PingFang SC;font-weight: 500;font-size: 28rpx;color: #1D2129;">
						<span>{{item['company']}}</span>
					</view>
					<view class="texts">
						<span>联系人: {{item['username']}}</span>
						<span>联系电话: {{item['phone']}}</span>
					</view>
					<view class="texts">
						<span>成交时间：{{formatDate(item['createtime']*1000)}}</span>
					</view>
					<view class="texts" style="margin-bottom: 30rpx;">
						<span>备注: {{item['memo']}}</span>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import headertop from '@/components/header.vue'
	import {
		onPageScroll,
		onReachBottom,
		onLoad,
		onShow
	} from "@dcloudio/uni-app";
	import {
		ref,
		onMounted,
		reactive,
		watch,
	} from 'vue'
	import {
		_static
	} from '@/ulm/utils/url.js'
	const back1 = ref('')
	const barHeight = ref('')
	const statusBarHeight = ref('')
	const activenum = ref(0)
	const total = ref(0)
	const contentobj = ref({})
	const list = ref([])
	const query = reactive({
		page: 1,
		limit: 10,
		type: 1
	})
	import {
		$api
	} from '../../ulm';
	watch(() => activenum.value, (newCount, oldCount) => {
		query['type'] = newCount + 1
		query['page'] = 1
		list.value = []
		init()
	});

	onPageScroll((e) => {
		if (e.scrollTop > 100) {
			back1.value = '#CAEEFF'
		} else {
			back1.value = ''
		}
	})
	onShow(() => {
		query.page = 1
		list.value = []
		init()
	})
	onReachBottom(() => {
		if (total.value > list.value.length) {
			query['page']++
			init()
		}
	})
	async function init() {
		const res = await $api.yongjinlist(query)
		if (res.code == 1) {
			contentobj.value = res.data
			list.value.push(...res.data.list)
			total.value = res.data.count
		}
	}
	//时间戳13位
	function formatDate(time) { //时间戳转日期
		let date = new Date(time);
		let y = date.getFullYear();
		let MM = date.getMonth() + 1;
		MM = MM < 10 ? ('0' + MM) : MM;
		let d = date.getDate();
		d = d < 10 ? ('0' + d) : d;
		let h = date.getHours();
		h = h < 10 ? ('0' + h) : h;
		let m = date.getMinutes();
		m = m < 10 ? ('0' + m) : m;
		let s = date.getSeconds();
		s = s < 10 ? ('0' + s) : s;
		return y + '-' + MM + '-' + d + ' ' + h + ':' + m

	}
	onMounted(() => {
		statusBarHeight.value = uni.getSystemInfoSync().statusBarHeight
		const {
			top,
			height
		} = wx.getMenuButtonBoundingClientRect();
		barHeight.value = height ? height + (top - statusBarHeight.value) * 2 : 38;
	})
</script>
<style lang="scss">
	.msgicon {
		width: 608rpx;
		margin: 100rpx auto;
		overflow: hidden;

		.msgtext {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #86909C;
			text-align: center;
			width: 100%;
			margin-top: 30rpx;
		}

		image {
			width: 608rpx;
		}
	}

	.yjc {
		width: 100%;
		overflow: hidden;
		position: relative;

		.yjcback {
			position: absolute;
			z-index: -1;
			width: 100%;
		}

		.bottomContent {
			width: 100%;
			overflow: hidden;
			position: relative;
			margin-top: -40rpx;

			.bottomContentback {
				width: 100%;
				position: absolute;
				z-index: -1;
			}

			.Contents {
				width: 686rpx;
				margin: auto;
				margin-top: 30rpx;
				overflow: hidden;

				.itemnr {
					width: 100%;
					background: #F7F8FA;
					border-radius: 16rpx 16rpx 16rpx 16rpx;
					overflow: hidden;
					margin-bottom: 24rpx;

					.texts {
						width: 638rpx;
						margin: auto;
						margin-top: 24rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 26rpx;
						color: #4E5969;
					}

					.linenr1 {
						width: 638rpx;
						margin: auto;
						overflow: hidden;
						height: 84rpx;
						border-bottom: 2rpx solid #FFFFFF;
						display: flex;
						justify-content: space-between;
						align-items: center;

						.tt {
							font-family: PingFang SC, PingFang SC;
							font-weight: 500;
							font-size: 32rpx;
							color: #1D2129;
						}

						.jine {
							font-family: PingFang SC, PingFang SC;
							font-weight: bold;
							font-size: 36rpx;
							color: #FF7D00;
						}
					}
				}
			}

			.activeboxline {
				width: 100%;
				display: flex;
				height: 90rpx;
				align-items: center;
				margin-top: 20rpx;

				.box1 {
					width: 50%;
					text-align: center;
					height: 90rpx;
					line-height: 90rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 32rpx;
					color: #23ACED;
					display: flex;
					flex-direction: column;
					align-items: center;
					position: relative;

					.activeb {
						width: 38rpx;
						height: 4rpx;
						background: #23ACED;
						border-radius: 2rpx 2rpx 2rpx 2rpx;
						bottom: 20%;
						position: absolute;
					}
				}

				.box {
					width: 50%;
					text-align: center;
					height: 90rpx;
					line-height: 90rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 32rpx;
					color: #1D2129;
				}
			}
		}

		.qbsy {
			width: 686rpx;
			overflow: hidden;
			margin: auto;
			margin-top: 28rpx;
			height: 390rpx;
			position: relative;

			.qbsyback {
				width: 100%;
				height: 390rpx;
				position: absolute;
				z-index: -1;
			}

			.qbsynum {
				margin-left: 36rpx;
				margin-top: 78rpx;
				overflow: hidden;

				.t1 {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #FFFFFF;
				}

				.numzijin {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 48rpx;
					color: #FFFFFF;
					margin-top: 22rpx;
				}
			}



			.centersy {
				width: 638rpx;
				margin: auto;
				margin-top: 32rpx;
				overflow: hidden;
				border-top: 2rpx solid rgba(255, 255, 255, 0.46);
				height: 144rpx;
				display: flex;
				align-items: center;

				.djsje {
					width: 320rpx;
					display: flex;
					flex-direction: column;
					align-items: center;

					.tt {
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #FFFFFF;
					}

					.numje {
						font-family: PingFang SC, PingFang SC;
						font-weight: bold;
						font-size: 40rpx;
						color: #FFFFFF;
						margin-top: 16rpx;
					}
				}
			}
		}
	}
</style>